Repository navigation
test(styled-tools): add unit tests - #296
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DXXPnGepYUGie3we1X9PTR
claude
Bot
requested review from
BeerHobbyist,
Komoszek,
alszczep,
kamilgacan,
katarzynagrasewicz,
konowrockis and
kumalg
as code owners
June 25, 2026 09:35
Komoszek
reviewed
Jun 25, 2026
| it("returns undefined for a path that does not exist on the theme", () => { | ||
| const { theme } = mkTheme<AppTheme>() | ||
|
|
||
| const missing = (theme.colors as any).tertiary as (c: ExecutionContext) => unknown |
Contributor
There was a problem hiding this comment.
But it implies bypassing typesafety of the theme. Does this test make sense?
Author
There was a problem hiding this comment.
Masz rację — ten test obchodził typesafety: sięgał po theme.colors.tertiary przez as any, czyli po klucz, którego AppTheme (i typ TransformDeep<TTheme>, którego cały sens to typowanie ścieżek) i tak nie dopuści w czasie kompilacji. Samo runtime'owe zachowanie "brakująca ścieżka → undefined" należy do mkProxy i jest już bezpośrednio pokryte w mkProxy.spec.ts ("returns undefined for a missing property on an object value"), na poprawnie typowanym Value. Test nie wnosił więc realnego pokrycia — usunąłem go.
… safety The removed test reached a key absent from AppTheme via an `as any` cast, exercising a path mkTheme's TransformDeep type forbids at compile time. The underlying missing-property runtime behavior is owned by mkProxy and already covered directly in mkProxy.spec.ts, so the test added no meaningful coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DXXPnGepYUGie3we1X9PTR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Sebastian Konowrocki · Slack thread
Before / After
@leancodepl/styled-toolspreviously had no tests. This PR adds 19 unit tests covering the package's entire public surface:mkProxy(13 tests): direct accessor invocation, lazy nested property traversal, deep multi-level resolution, theprototypespecial case (returnsFunction.prototype), proxy caching (same reference for repeated access, distinct proxies per key), per-invocation re-evaluation against the execution context, symbol-keyed access, and the guard edge cases (property access on string/number/null/missing/undefinedvalues all resolve toundefined).mkTheme(6 tests): the returned{ theme, useTheme }shape, thethemeproxy reading nested values out of the styled-componentsExecutionContext(including theme switching and non-existent paths), and theuseThemehook resolving the activeThemeProvidertheme via@testing-library/react'srenderHook.How
Mirrored the vitest conventions of sibling packages (jsdom env,
renderHook+ThemeProviderfor the hook). Added@testing-library/react,react, andvitesttodevDependenciesto satisfy the workspace lint rules, matching how other tested packages declare them. All of:test,:typecheck,:lint, and:buildpass locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01DXXPnGepYUGie3we1X9PTR
Generated by Claude Code